import axios from 'axios'
const userBaseUrl = import.meta.env.VITE_BASE_URL

// 封装事件请求
function eventHttp({url,method,event_status}){
  return axios({
    url: userBaseUrl + url,
    method,
    data:{
      event_status
    }
  })
}

// 获取所有用户
const getAllEventhttp = (keyword)=>{
  if(!keyword){
    keyword = ''
  }
  return eventHttp({
    url:`/event?keyword=${keyword}`,
    method:'get'
  })
}

//审核功能
const putEventHttp = (event_id,event_status)=>{
  if( event_status != 2){
    event_status = '1'
  }else if(event_status == 2){
    event_status = '2'
  }

  return eventHttp({
    url: `/event/${event_id}`,
    method: 'put',
    event_status
  })
}

//根据id获取用户
const getOneEventhttp = (event_id) => {
  return eventHttp({
    url:`/event/${event_id}`,
    method:'get',
  })
}


export {
  getAllEventhttp,
  putEventHttp,
  getOneEventhttp
}